﻿<CodeSnippets
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>spchol307_ex1_webpart_getprojectdetails</Title>
      <Shortcut>spchol307_ex1_webpart_getprojectdetails</Shortcut>
      <Description>Code snippet for SPCHOL307 Ex2 GetProjectDetails</Description>
      <Author>Microsoft Corporation</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="vb">
        <![CDATA[Protected Overrides Sub OnLoad(ByVal e As EventArgs)
    MyBase.OnLoad(e)
    If Not Page.IsPostBack Then
        GetProjectDetails()
    End If
End Sub

Private Sub GetProjectDetails()
    EnsureChildControls()
    If _ddlProjects.SelectedValue <> "-- Select a Project --" Then
        Dim list As SPList = SPContext.Current.Web.Lists.Item("Projects")
        Dim id As Integer = Convert.ToInt32(_ddlProjects.SelectedValue)
        Dim itemById As SPListItem = list.GetItemById(id)
        _tbDescription.Text = itemById.Item("Description").ToString
        _tbDueDate.Text = Convert.ToDateTime(itemById.Item("Due_x0020_Date")).ToShortDateString
    Else
        _tbDescription.Text = String.Empty
        _tbDueDate.Text = String.Empty
    End If
End Sub]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>
